#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 1023;
int C[MAXN][MAXN];
vector<int> vec[MAXN];
int arr[MAXN];
int res[MAXN]; 
int in_du[MAXN];
int vis[MAXN];
int n,k;
void Init(int n) {
    for (int i=0; i<n; ++i) {
        memset(C[i], 0, sizeof(int)*(n));
        vec[i].clear();
    }
    memset(vis, 0, sizeof(int)*n);
    memset(in_du, 0, sizeof(int)*n);
}

bool check1(int now)
{
    int len = vec[now].size();
    vis[now] = 1;
    for(int i=0;i<len;++i)
    {
        int tar = vec[now][i];
        if(vis[tar] == 2)continue;
        if(vis[tar] == 1)return false;
        if(!check1(tar))return false;
    }vis[now] = 2;
    return true;
}

void TopSort() {
    priority_queue<int> pq;
    int cnt = 0;
    pq.push(0);
    while (!pq.empty()) {
        while (!pq.empty()) {
            int pre = -pq.top(); pq.pop();
            res[cnt++] = pre;
            int len = vec[pre].size();
            for (int i=0; i<len; ++i) {
                int t = vec[pre][i];
                --in_du[t];
                if (in_du[t]==0) pq.push(-t);
            }
        }
    }
}

void show(int n) {
    for (int i=0; i<=n; ++i) {
        int len = vec[i].size();
        printf("%d: ", i);
        for (int j=0; j<len; ++j) printf("%d ", vec[i][j]);
        printf("\n");
    }
}

int main() {
    while (scanf("%d %d", &n, &k)) {
        if (n==0 && k==0) break;
        Init(n+7);
        int t;
        for (int i=0; i<k; ++i) {
            for (int j=0; j<n; ++j) {
                scanf("%d", &t);
                for (int l=0; l<j; ++l) {
                    ++C[arr[l]][t];
                }
                arr[j] = t;
            }
        }
        for (int i=1; i<=n; ++i) {
            for (int j=1; j<i; ++j) {
                if (C[i][j] == k/2 && !(k&1)) continue;
                // else if (C[i][j] > k/2) vec[j].push_back(i), ++in_du[i];
                // else vec[i].push_back(j), ++in_du[j];

                else if (C[i][j] > k/2) vec[i].push_back(j), ++in_du[j];
                else vec[j].push_back(i), ++in_du[i];
            }
        }
        bool flag = false;
        for (int i=1; i<=n; ++i) {
            if (in_du[i]==0) vec[0].push_back(i), ++in_du[i], flag=true;
        }
        if (check1(0) == false || !flag) {
            printf("No solution\n");
        } else {
            TopSort();
            // for (int i=n; i>=1; --i) {
            //     printf("%d", res[i]);
            //     if(i!=1)printf(" ");
            // }
            // printf("\n");
            for (int i=1; i<=n; ++i) {
                printf("%d", res[i]);
                if(i!=n)printf(" ");
            }
            printf("\n");
        }
    }
    return 0;
}
